from flask import Flask, request
from flask_cors import CORS
import json

app = Flask(__name__,template_folder='./build',static_folder="./build")
CORS(app,resources=r'/*')


@app.route('/')
def hello_world():
    return 'hello world'


@app.route('/axios-get/<srcpath>')
def axios_get(srcpath):
    print(srcpath)
    page = open('./build/' + srcpath, encoding='utf-8')
    res = page.read()
    return res

@app.route('/axios-post')
def axios_post():
    page = open('axios-post.html', encoding='utf-8')
    res = page.read()
    return res

@app.route('/getT', methods=['get'])
def getT():
    students = [{"id":str(i),"name":"x"+str(i),"url":"111"} for i in range(10) ]
    return json.dumps(students)

@app.route('/postT', methods=['post'])
def postT():
    return request.form

if __name__ == '__main__':
    app.run(port=9000, debug=True)
